use serde::Serialize;

#[derive(Serialize)]
pub struct Rest<T> {
    pub code: i16,
    pub message: String,
    pub data: Option<T>,
}

impl<T> Rest<T> {
    pub fn ok(data:T)->Self {
        Rest{
            code: 200,
            message: "Success".to_string(),
            data: Some(data),
        }
    }

    pub fn err(message: String) -> Self {
        Rest {
            code: 500,
            message,
            data: None,
        }
    }
}
